#include <cstdio>
#include <algorithm>
using namespace std;
typedef struct
{
    int id;
    int dScore, cScore;
    int cls; //class：考生类别
} nod_t;
bool cmp(nod_t nodl, nod_t nodr)
{ //按照排序的优先级来组织cmp函数
    if (nodl.cls != nodr.cls)
        return nodl.cls < nodr.cls;
    else if (nodl.dScore + nodl.cScore != nodr.dScore + nodr.cScore)
        return nodl.dScore + nodl.cScore > nodr.dScore + nodr.cScore;
    else if (nodl.dScore != nodr.dScore)
        return nodl.dScore > nodr.dScore;
    else
        return nodl.id < nodr.id;
}
int main()
{
    int N, L, H, M = 0;
    int tmp = 0;
    nod_t stu[100001];
    scanf("%d%d%d", &N, &L, &H);
    while (N--)
    { //边读边统计人数，同时标记考生类别
        scanf("%d%d%d", &stu[M].id, &stu[M].dScore, &stu[M].cScore);
        if (stu[M].dScore >= L && stu[M].cScore >= L)
        { //更新人数
            ++tmp;
        }
        else
            continue; //不记入数组直接进行下一次循环
        if (stu[M].dScore >= H)
        {
            if (stu[M].cScore >= H)
                stu[M].cls = 1;
            else
                stu[M].cls = 2;
        }
        else
        {
            if (stu[M].dScore > stu[M].cScore)
                stu[M].cls = 3;
            else
                stu[M].cls = 4;
        }
        M = tmp;
    }
    printf("%d\n", M);
    sort(stu, stu + M, cmp);
    for (int i = 0; i < M; ++i)
    {
        printf("%d %d %d\n", stu[i].id, stu[i].dScore, stu[i].cScore);
    }
    return 0;
}